<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Admin\Model;

use Think\Model;

class PushPackageModel extends Model {

        protected $_validate=array(
                  array("title","require","名称格式不正确",1,"regex"),
                  array("money","currency","金额格式不正确",1,"regex"),
                );

        //根据id查询代写服务套餐信息
        public function getPushPackageList($where=""){

            $res=getPages($this,$where);            
            return $res;
        }
         //根据id查询代写服务套餐信息
        public function getPackageById($id){

           $res=$this->where("id=%s",$id)->find();
            return $res;
        }

        //添加、修改代写服务套餐信息
        public function editData($data){

            if(!$data) {
                $this->error="数据不能为空";
                return false;
            }
            if(!$this->create($data)){
                $this->error=$this->getError();
                return false;
            }
            if(empty($data["id"])){

                $res=$this->add();
                if(!$res){
                    $this->error="添加失败，请重试";
                    return false;
                }
            }else{
                $res=$this->save();
                if($res==false){
                    $this->error="修改失败，请重试";
                    return fasle;
                }
            }
            return true;
        }
        //删除套餐信息
        public function delData($data){

            $res=$this->where(array("id"=>array("in",$data)))->delete();
            return $res;
        }
    
   }


?>
